import React, { Component } from 'react';
import { SolveDetailCol, SolveDetail, Line, SovleDataUl, SovleDataLi } from './Styled';
import { connect } from 'dva';

import ShowItem from './ShowItem';
import Imgviewer from '@/components/ImgViewer';

const depart = ['保安组', '消防主管', '工程部', '管理员', '消防责任人']

@connect()
class Solving extends Component {
  state = {};

  render() {
    const { data = {}, analyse = false } = this.props;
    const logs = data.pushLogList || [];
    return (
      <section>
        <SolveDetail>
          <SolveDetailCol analyse={analyse.toString()}>{`发生${data.typeName}`}
          </SolveDetailCol>
          {
            depart.map((item, index) => (
              <span key={index}>
                <Line analyse={analyse.toString()} width="50px" />
                <SolveDetailCol analyse={analyse.toString()} width="90px">
                  {`${data.typeName}信息推送至${item}: `}
                  {logs[index] && logs[index] && Array.isArray(logs[index].receiverName) && logs[index].receiverName[0] ? `${logs[index].receiverName[0] || ''}等` : <span>暂无</span>}
                </SolveDetailCol>
              </span>
            ))
          }
          <Line analyse={analyse.toString()} width="50px" />
          <SolveDetailCol analyse={analyse.toString()}>{`${data.typeName}未处理`}</SolveDetailCol>
        </SolveDetail>
        <SovleDataUl>
          <SovleDataLi width="100px" style={{ marginRight: '23px' }}>
            {data.createTime}
            <p>
              {
                Array.isArray(data.file) && data.file.map((it, index) => <Imgviewer key={index} isThumb={true} url={it} />)
              }
            </p>
          </SovleDataLi>
          {
            logs && logs.filter((it, index) => index < 6).map((item, index) => (
              <SovleDataLi key={index} width="100px" style={{ marginRight: '60px' }}>
                <p>{item.createTime}</p>
                <p>{item.statusName}</p>

              </SovleDataLi>
            ))
          }
        </SovleDataUl>
      </section>
    );
  }
}

export default ShowItem(Solving);
